package info.nixbear.tgcms.admin.shared.request;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.web.bindery.requestfactory.gwt.client.DefaultRequestTransport;

public class RequestModule extends AbstractGinModule {

	@Override
	protected void configure() {
	}

	@Provides
	@Singleton
	AdminRequestFactory provideMyAppRequestFactory(EventBus eventBus) {
		
		AdminRequestFactory requestFactory = GWT.create(AdminRequestFactory.class);

		DefaultRequestTransport requestTransport = new DefaultRequestTransport();
		requestTransport.setRequestUrl( GWT.getHostPageBaseURL() + "admin/gwtRequest");
		
		requestFactory.initialize(eventBus, requestTransport);
		
		return requestFactory;
	}

}
